// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"

#include "Framework/BaseController.h"
#include "NetworkController.generated.h"

UCLASS()
class MISCELLANEOUSPROJECT_API ANetworkController : public ABaseController
{
	GENERATED_BODY()
protected:
	DECLARE_EVENT_FourParams(ANetworkController, FOnReceiveMessage, APlayerState*, FString, FName, float);
	FOnReceiveMessage OnReceiveMessageEvent;
public:
	ANetworkController();

	UFUNCTION(reliable, client)
	void ClientStartOnlineGame();

	UFUNCTION(reliable, client)
	void ClientEndOnlineGame();

	//===================聊天功能=================================
	UFUNCTION(Exec)
	void Say(FString Message);

	UFUNCTION(unreliable, server, WithValidation)
	void ServerSay(const FString& Msg);

	FOnReceiveMessage& OnReceiveMessage() { return OnReceiveMessageEvent; }
	virtual void ClientTeamMessage_Implementation(APlayerState* SenderPlayerState, const FString& S, FName Type, float MsgLifeTime) override;

private:
	FTimerHandle TimerHandle_ClientStartOnlineGame;

	FName ChartType;
};
